﻿//https://leetcode.cn/problems/number-of-students-unable-to-eat-lunch/

class Solution {
public:
    int countStudents(vector<int>& students, vector<int>& sandwiches)
    {
        int s0 = 0, s1 = 0;
        for (auto& e : students)
        {
            if (e == 1)
                s1++;
            else
                s0++;
        }

        for (int i = 0; i < sandwiches.size(); i++)
        {
            if (sandwiches[i] == 1 && s1 > 0)
            {
                s1--;
            }
            else if (sandwiches[i] == 0 && s0 > 0)
            {
                s0--;
            }
            else
            {
                //有一个三明治谁都不喜欢吃
                break;
            }
        }
        return s1 + s0;
    }
};